<form method="POST" id="new_devis" action="javascript:newDevis();">
<input id="devis_id" name="devis_id" type="hidden"/> 
	<div id="crer_devis_tabs">
		<ul>
			<li><a href="#client"> Client </a></li>
			<li><a href="#entetes"> Entêtes </a></li>
			<li><a href="#devis"> Corps du devis </a></li>
			<li><a href="#recap"> Pieds de page </a></li>
		</ul>
		
		<div id="client">
			<table id="carnetAddress">
				<thead>
					<tr>
						<th> </th>
						<th> Nom </th>
						<th> Adresse </th>
					</tr>
				</thead>
				<? foreach($aContacts as $contact){
					$contact_name = $contact->nom." ".$contact->prenom;
					$adresse = $contact->adresse_rue." ".$contact->adresse_cp." ".$contact->adresse_ville;
				?>
				<tr>
					<td><center><input type="radio" id="contact_<?=$contact->_id?>" name="contact_id" value="<?=$contact->_id?>"/></center></td>
					<td><?=$contact?></td>
					<td><?=$adresse?></td>
				</tr>
				<? }?>
			</table>
		</div>
		<div id="entetes">
			<table style="width:70%;margin-left:15%;">
				<tr>
					<th> Date du devis </th>
					<td> <input type="text" class="datepicker" name="date" value=""/></td>
					<th> Date de validité du devis </th>
					<td> <input type="text" class="datepicker" name="echeance"/></td>
				</tr>
				<tr>
					<th> Remise globale </th>
					<td> <input type="text" style="width:50px" name="remise" id="remise" onKeyUp="calc_line();"/> %</td>
					<th> Type de règlement : </th>
					<td><select name="type_reglement">
						<?foreach($typesReglements as $type){?>
						<option id="option_type_reglement_<?=$type->_id?>" value="<?=$type->_id?>"> <?=$type->libelle?></option>
						<?}?>
					</select></td>
				</tr>
				
				<tr>
					<th> Accompte </th>
					<td> <input type="text" style="width:100px" id="accompte" onKeyUp="calc_line();"/> &euro;</td>
					<th> Référence de la commande </th>
					<td><input type="text" name="ref_commande"/></td>
				</tr>
			</table>
		</div>
		<div id="devis">
			<table id="devis_lines">
				<thead>
					<tr>
						<th> Désignation </th>
						<th> Qté </th>
						<th> Prix HT </th>
						<th> TVA </th>
						<th> Montant HT </th>
						<th> Plan comptable </th>
					</tr>
				</thead>
				<?for($i=1;$i<=20;$i++){?>
				<tr>
					<td><textarea style="height:50px;width:300px;" id="desc_<?=$i?>" name="lines[<?=$i?>][description]"></textarea></td>
					<td><input type="text" class="lines" id="qte_<?=$i?>" name="lines[<?=$i?>][qte]" onKeyUp="calc_line('<?=$i?>');"/> </td>
					<td><input type="text" class="lines" id="ht_<?=$i?>"name="lines[<?=$i?>][montant_ht]" onKeyUp="calc_line('<?=$i?>');"/> </td>
					<td><select name="lines[<?=$i?>][taux_tva]" id="tva_<?=$i?>" onChange="calc_line('<?=$i?>');">
						<?foreach($aTVA as $tva){?>
							<option id="option_tva_<?=$i?>_<?=$pc->code?>" value="<?=$tva->_id?>"><?=$tva->taux?>%</option>
						<?}?>
						</select>
					</td>
					<td><input type="text" class="lines" disabled="true" id="montant_ht_<?=$i?>" value="0.00€"/> </td>
					<td><select style="text-align:left;" id="plan_<?=$i?>" name="lines[<?=$i?>][plan]">
						<?foreach($planComptable as $pc){?>
							<option id="option_plan_<?=$i?>_<?=$pc->code?>" value="<?=$pc->code?>"><?=$pc->libelle?></option>
						<?}?>
						</select>
					</td>
				</tr>
				
				<?}?>
			</table>
		
		</div>
		<div id="recap">
			<table>
				<tr>
					<th> Montant total H.T </th>
					<td><span id="tot_ht">0.00 €</span> <input type="hidden" name="montant_ht"/></td>
					<th> Montant T.T.C </th>
					<td><span id="tot_ttc">0.00 €</span><input type="hidden" name="montant_ttc"/></td>
				</tr>
				<tr>
					<th> Montant TVA 5.5% </th>
					<td><span id="montant_55">0.00 €</span><input type="hidden" name="montant_55"/></td>
					<th> Montant TVA 19.6 </th>
					<td><span id="montant_196">0.00 €</span><input type="hidden" name="montant_196"/></td>
				</tr>
				<tr>
					<th> Remise </th>
					<td><span id="montant_remise">0.00 €</span><input type="hidden" name="montant_remise"/></td>
					<th> Accompte </th>
					<td><span id="montant_accompte">0.00 €</span><input type="hidden" name="accompte"/></td>
				</tr>			
				<tr>
					<td></td>
					<td></td>
					<th> Total à payer </th>
					<td><span id="a_payer">0.00 €</span><input type="hidden" name=""/></td>
				</tr>
			</table>
		</div>
	</div>
</form>